#include "../augmentOpencv/augmentOpencv.h"
#include "testerHeader.h"

void test1(void) {
	CvMat *mat = cvCreateMat(5, 5, CV_8U);
	cvZero(mat);
	cvSet2D(mat, 1, 1, cvScalar(255));
	cvSet2D(mat, 2, 3, cvScalar(255));
	cvSet2D(mat, 2, 2, cvScalar(255));
	cvSet2D(mat, 3, 2, cvScalar(255));
	cvSet2D(mat, 3, 3, cvScalar(255));
	cvSet2D(mat, 4, 1, cvScalar(255));
	cvSet2D(mat, 1, 4, cvScalar(255));
	CvPointListList pllist = cvBwlabel(mat);
	cvEzPrintMat(mat);
	for (int i=0; i<pllist.length; ++i)
		cout << pllist.lists[i]->length << endl;

	double minval, maxval;
	int minidx, maxidx;
	cvSet2D(mat, 3, 3, cvScalar(2));
	cvMinMaxLoc(mat, *pllist.lists[2], minval, maxval, minidx, maxidx);
	cout << minval << " " << minidx << endl;
	cout << maxval << " " << maxidx << endl;
}
void test2(void) {
	CvMat *img = cvLoadImageM("1.jpg");
	cvShowImage("img", img);
	CvHistogram *pHist;
	int nHistBins = 20;
	float *pRanges = new float[2];pRanges[0] = 0;pRanges[1] = 255;
	pHist = cvCreateHist( 1, &nHistBins, CV_HIST_ARRAY, &pRanges, 1 );

	cvCalcArrHist((CvArr**)(&img), pHist);
	cvShowHist(pHist);
	cvWaitKey(0);
}

void test3(void) {
	CvMat *img = cvCreateMat(3,3,CV_8UC3);
	for (int i=0; i<3; ++i)
		for (int j=0; j<3; ++j)
			cvSet2D(img, i, j, cvScalar(i, j, i*10+j));
	cvEzPrintMat(img);
	uchar* ptr = img->data.ptr;
	for (int i=0; i<9; ++i) {
		for (int j=0; j<3; ++j, ++ptr)
			cout << int(*ptr) << " " ;
		cout << endl;
	}
}

void test4(void) {

}

int main(void) {
	test4();
	return 0;
}
